package cn.cerc.sample.forms;

import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import cn.cerc.mis.core.IPage;
import cn.cerc.mis.security.MenuGroupEnum;
import cn.cerc.mis.security.Permission;
import cn.cerc.mis.security.Webform;
import cn.cerc.sample.ui.CustomForm;
import cn.cerc.sample.ui.UICustomPage;
import cn.cerc.ui.vcl.UIDiv;
import cn.cerc.ui.vcl.UIImage;
import cn.cerc.ui.vcl.UISpan;
import cn.cerc.ui.vcl.UIText;
import cn.cerc.ui.vcl.UIUrl;
import cn.cerc.ui.vcl.ext.UIHtmlFile;

@Webform(module = "", name = "欢迎使用 summer-sample", group = MenuGroupEnum.其它工具)
@Permission(Permission.GUEST)
@Component("welcome")
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class FrmWelcome extends CustomForm {

    @Override
    public IPage execute() {
        UICustomPage page = new UICustomPage(this);
        page.addCssFile("css/welcome.css");
        UIDiv div = new UIDiv(page.getContent()).setCssClass("welcome");
        UIDiv content = new UIDiv(div);
        new UISpan(content).setText("欢迎使用Summer-sample");
        UIDiv contentDiv = new UIDiv(content).setCssClass("contentDiv");
        UIDiv topDiv = new UIDiv(contentDiv).setCssClass("topDiv");

        UIDiv div1 = new UIDiv(topDiv);
        UIText text = new UIText(div1);
        text.add("此项目有助于您快速学习summer框架的使用方法");
        text.add("新的项目也可以以此为基础，快速建立");

        UIDiv div2 = new UIDiv(topDiv).setCssClass("oneDiv");
        UIUrl pc = new UIUrl(div2).setSite("welcome?device=pc");
        new UIImage(pc).setSrc("images/pc.png");
        new UISpan(pc).setText("进入网页版");

        UIUrl phone = new UIUrl(div2).setSite("welcome?device=phone");
        new UIImage(phone).setSrc("images/phone.png");
        new UISpan(phone).setText("进入手机版");

        // ------正式演示------
        UIDiv div3 = new UIDiv(topDiv);
        new UISpan(div3).setText("简易进销存系统");

        UIDiv div4 = new UIDiv(topDiv).setCssClass("flexDiv");
        UIUrl two = new UIUrl(div4).setSite("FrmEmployeeV2");
        new UIImage(two).setSrc("images/item.png");
        new UISpan(two).setText("员工管理");
        new UISpan(two).setText("（示例-第二代写法）");

        UIUrl three = new UIUrl(div4).setSite("FrmEmployeeV3");
        new UIImage(three).setSrc("images/item.png");
        new UISpan(three).setText("员工管理");
        new UISpan(three).setText("（示例-第三代写法）");

        UIDiv bottomDiv = new UIDiv(contentDiv);

        new UIUrl(bottomDiv).setText("商品管理").setSite("FrmPartInfo");

        new UIUrl(bottomDiv).setText("订单管理").setSite("FrmTranOrder");

        new UIUrl(bottomDiv).setText("订单统计").setSite("FrmOrderReport");

        if (!this.getClient().isPhone()) {
            new UIHtmlFile(page.getFooter()).setFileName("/html/copyright.html");
        }
        return page;
    }

}
